home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / PROBLEMS / BENCHMARK / BUBBLESORT / bubbletest / formula / source < prev    next >
Text File  |  1992-05-15  |  783b  |  46 lines

  1.  ;; use with !formula $.outfile thisfile
  2.  
  3.  ;INCLUDE <formula$dir>.function_h
  4.  
  5. ;FUNCTION INT bubblesort(INTPTR a,INT length)
  6.    ;DO 
  7.      ;LET R0=0;
  8.      ;FOR (R3=0;R3<length-1;R3=R3+1)
  9.         ;IF a[R3]>a[R3+1]
  10.            ;LET R4=a[R3]
  11.            ;LET a[R3]=a[R3+1]
  12.            ;LET a[R3+1]=R4
  13.            ;LET R0=1;
  14.         ;ENDIF
  15.      ;ENDFOR 
  16.   ;ENDDO R0 
  17. ;ENDFUNCTION
  18.  
  19.  goto jump
  20.  
  21. ;INT a[1000]
  22.     
  23. jump
  24.  
  25.  ;LET system("*wimpslot -min 11K -max 11K") 
  26.  
  27. ; pseudo ramdom
  28.  ;LET R0=123456;
  29.  ;FOR (R1=0;R1<1000;R1=R1+1)
  30.      ;LET R0=(R0 + 234567) % 567 + 345
  31.      ;LET a[R1]=R0;
  32.      ;LET writeint(a[R1])
  33.      cr
  34.  ;ENDFOR
  35.  
  36.  ;LET system("time")
  37.  ;LET bubblesort(a,1000)
  38.  ;LET system("time") 
  39.  
  40.  ;FOR (R1=0;R1<1000;R1=R1+1)
  41.      ;LET writeint(a[R1])
  42.      cr
  43.  ;ENDFOR 
  44.   SWI XOS_Exit
  45.  .END
  46.